from django.contrib import admin
from django.urls import path, include
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from rest_framework.permissions import AllowAny

# 使用 drf-yasg 的默认配置
schema_view = get_schema_view(
    openapi.Info(
        title="API 文档",
        default_version='v1',
        description="自动生成的接口文档",
    ),
    public=True,
    permission_classes=[AllowAny],  # 允许所有用户访问文档
)

urlpatterns = [
    path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
    path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
    path('admin/', admin.site.urls),  # 管理员界面
    path('api/users/', include('users.urls')),  # 用户模块
    path('api/products/', include('products.urls')),  # 商品模块
    path('api/orders/', include('orders.urls')),
]